package com.jhsw.roadsun.module.business.dal.mysql.user;

import com.jhsw.roadsun.framework.common.pojo.PageResult;
import com.jhsw.roadsun.framework.mybatis.core.mapper.BaseMapperX;
import com.jhsw.roadsun.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.jhsw.roadsun.module.business.controller.admin.user.vo.BizUserPageReqVO;
import com.jhsw.roadsun.module.business.controller.admin.user.vo.BizUserRespVO;
import com.jhsw.roadsun.module.business.dal.dataobject.user.BizUserDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户信息 Mapper
 *
 * @author Ysugar
 */
@Mapper
public interface BizUserMapper extends BaseMapperX<BizUserDO> {

    default PageResult<BizUserRespVO> selectPage(BizUserPageReqVO reqVO) {
        return selectJoinPage(reqVO, BizUserRespVO.class, new MPJLambdaWrapperX<BizUserDO>()
                .selectAll(BizUserDO.class)
                .eqIfPresent(BizUserDO::getMobile, reqVO.getMobile())
                .likeIfPresent(BizUserDO::getNickname, reqVO.getNickname())
                .eqIfPresent(BizUserDO::getStatus, reqVO.getStatus())
                .eqIfPresent(BizUserDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(BizUserDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BizUserDO::getId));
    }
}